#include <iostream>
// cin.get() 读空行返回 false
// in-block static variable 'total' retains its value between function calls
// 函数默认是 extern，所以一起编译的文件不能有重名函数，即使没有互相调用
const int ArSize = 10;
void strcount(const char *str);
void hello();

int main(){
    using namespace std;

    char input[ArSize];
    char next;

    hello();
    cout << "Enter a line:" << endl;
    cin.get(input, ArSize);
    while (cin)
    {
        cin.get(next);
        while(next != '\n')
            cin.get(next);
        
        strcount(input);
        cout << "Enter next line (empty line to quit):" << endl;
        // cin.get(input, ArSize);
    }
    cout << "Bye" << endl;
    return 0;
}

void strcount(const char * str){
    using namespace std;
    static int total = 0;
    int count = 0;

    while(*str++)
        ++count;
    total += count;
    cout << count << " - " << total << endl;
}